<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="breadcrumbs" id="breadcrumbs">
                            <script type="text/javascript">
                                try {
                                    ace.settings.check('breadcrumbs', 'fixed')
                                } catch (e) {
                                }
                            </script>
                            <ul class="breadcrumb">
                                <li>
                                    <i class="ace-icon fa fa fa-rmb"></i>
                                    <a href="javascript:;">分期账单</a>
                                </li>
                            </ul><!-- /.breadcrumb -->
                        </div>
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                <th>还款日期</th>
                                <th>期数</th>
                                <th>还款金额</th>
                                <th>总金额</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if($loan_stage){ foreach ($loan_stage as $key => $val) { ?>
                                <tr>
                                    <td class="center">
                                        <input class="uids" type="checkbox" name="uids[]" value="{$val['uid']}">
                                    </td>
                                    <td><?php echo $val['back_date']; ?></td>
                                    <td><?php echo $val['stage_num']; ?></td>
                                    <td><?php echo $val['per_stage_money']; ?></td>
                                    <td><?php echo $val['stage_money']; ?></td>
                                    <td class="center">
                                        <?php if($val['is_return'] == 0){?>
                                            <a href="javascript:;" onclick="return_money(<?php echo $val['id'];?>)">确认还款</a>&nbsp;&nbsp;
                                        <?php } ?>
                                        <?php if($val['is_return'] == 1){?>
                                            <span class="label label-warning arrowed arrowed-right">已还款</span>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } }?>
                            </tbody>
                        </table>
                        <input type="hidden" id="uid" name="uid" value="<?php if(!empty($member['user_id'])){  echo $member['user_id'];}?>">
                        <div class="col-md-offset-2 col-md-9">
                            <span class="btn btn-purple btn-sm">
                                <span class=" icon-on-right bigger-110"></span>
                                返回
                            </span>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    function return_money(id) {

        var locationurl = baseurl+"index.php/manage/member/return_money_fenqi";
        $.ajax({
            url:locationurl,
            type:"get",
            data:{'return_id':id},
            dataType: 'json',
            success: function(data){
                console.log(data);
                if(data.code == 200){
                    layer.msg('还款成功', {
                        time: 1000, //1s后自动关闭
                        shade: 0.1
                    },function () {
                        window.location.href = window.location.href;
                    });
                }else{
                    console.log(data);
                    layer.msg(data.msg);
                }
            }
        });
    }


</script>
</body>
</html>
